/* eslint valid-jsdoc: "off" */

'use strict'

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {})

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1623921719258_7368'

  // add your middleware config here
  config.middleware = []

  // 去掉csrf验证
  config.security = {
    csrf: {
      enable: false,
    },
  }
  config.errorHandler = {
    // 通用配置（以下是重点）
    enable: true, // 控制中间件是否开启。
  }
  // 可跨域类型
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  }
  // 请求体限制大小
  config.bodyParser = {
    jsonLimit: '1mb',
    formLimit: '10mb',
  }

  config.multipart = {
    fileSize: '50mb',
    mode: 'file',
    fileExtensions: ['.xlsx', '.xls'], // 上传文件的格式限制
  }

  config.jwt = {
    secret: 'bangche',
    options: {
      // expiresIn: '1ms',
    },
    whiteList: ['*/mina'],
  }

  // add your user config here
  const userConfig = {
    aliyun: {
      oss: require('./aliyun/oss'),
    },
    wechat: {
      config: require('./wechat/config'),
    },
  }

  return {
    ...config,
    ...userConfig,
  }
}
